from typing import Optional, List, Dict, Any, Union
from pydantic import BaseModel, Field


class ButtonConfig(BaseModel):
    """工具栏按钮配置模型"""
    text: str = ""
    icon: Optional[str] = None
    callback_name: Optional[str] = None
    tooltip: Optional[str] = None
    shortcut: Optional[str] = None
    checkable: bool = False
    checked: bool = False
    separator_before: bool = False
    separator_after: bool = False
    submenu: List["ButtonConfig"] = Field(default_factory=list)


class ToolbarConfig(BaseModel):
    """工具栏配置模型"""
    barname: str
    items: List[ButtonConfig] = Field(default_factory=list)
    movable: bool = True
    floatable: bool = True
    area: str = "top"


class MenuConfig(BaseModel):
    """菜单配置模型"""
    title: str
    toolbars: List[ToolbarConfig] = Field(default_factory=list)


class DockWidgetConfig(BaseModel):
    """停靠窗口配置模型"""
    title: str
    area: str = "left"  # left, right, bottom
    widget_type: Optional[str] = None
    widget_config: Dict[str, Any] = Field(default_factory=dict)
    closable: bool = True
    floating: bool = False


class AppConfig(BaseModel):
    """应用程序配置模型"""
    title: str = "PySide6 Application"
    version: str = "1.0.0"
    window_size: tuple = (800, 600)
    window_position: tuple = (100, 100)
    menus: List[MenuConfig] = Field(default_factory=list)
    dock_widgets: List[DockWidgetConfig] = Field(default_factory=list)
    
    class Config:
        arbitrary_types_allowed = True 